package lnu.project.cart;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AddNewBasket extends Activity{
	
	
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.newbasket_xml);
        
        Button ok_button = (Button)findViewById(R.id.ok);
        ok_button.setOnClickListener(new ButtonClick());
        
        Button cancel_button = (Button)findViewById(R.id.cancel);
        cancel_button.setOnClickListener(new CancelButtonClick());
	}
	
	
    private class ButtonClick implements View.OnClickListener {
    	public void onClick(View v) {
    		EditText reader = (EditText)findViewById(R.id.name);
    		String name = reader.getText().toString();
    		
    		/* Create new result intent */
    		Intent reply = new Intent();
    		reply.putExtra("result", name);
    		reply.putExtra("flag", "0");
    		setResult(RESULT_OK,reply);
    		finish();
        }
    }
    
    private class CancelButtonClick implements View.OnClickListener {
    	public void onClick(View v) {
    		
    		setResult(RESULT_CANCELED, null);
    		finish();
        }
    }
}
